package groovysql

import groovy.sql.Sql

println(":=")


//数据库地址
def url = "jdbc:oracle:thin:@10.10.65.104:1521:ufgovdb1"
//用户名
def username = "phdev_jzk_20191125"
//密码
def password = "crux"

def sql = Sql.newInstance(url, username, password, "oracle.jdbc.driver.OracleDriver")
sql.connection.autoCommit = false

sql.eachRow("select id,code,name from org_region", { regionRow ->
    println("遍历区划:${regionRow.name}(${regionRow.code})-----------------id in (${regionRow.id})")
    sql.eachRow("select * from permission_per_assignment where dbms_lob.instr(resource_id,:resourceId,0,1)>0", [resourceId: "id in (${regionRow.id})"], { paRow ->
        println("   遍历PA:${regionRow.name}(${regionRow.code})---->${paRow.subjectId}")
    })
})
sql.close()
